package unittest;

import junit.framework.TestCase;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import tester.Comparator;
import tester.TolerantComparator;
import tester.ComparationException;

/**
 * Created by IntelliJ IDEA.
 * User: aleck
 * Date: 2007-9-21
 * Time: 12:45:43
 * To change this template use File | Settings | File Templates.
 */
public class TolerantComparatorTest extends TestCase {
  private static final Comparator comparator = new TolerantComparator();
  public void testNoDiff() {
    try {
      FileInputStream f1 = new FileInputStream("temp\\a1.txt");
      FileInputStream f2 = new FileInputStream("temp\\a2.txt");
      assertEquals(comparator.compare(null, f1, f2, null, null), 100);
    } catch (FileNotFoundException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
  }
  public void testLineDiff() {
    try {
      FileInputStream f1 = new FileInputStream("temp\\b1.txt");
      FileInputStream f2 = new FileInputStream("temp\\b2.txt");
      assertEquals(comparator.compare(null, f1, f2, null, null), 100);
    } catch (FileNotFoundException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
    try {
      FileInputStream f1 = new FileInputStream("temp\\c1.txt");
      FileInputStream f2 = new FileInputStream("temp\\c2.txt");
      assertEquals(comparator.compare(null, f1, f2, null, null), 0);
    } catch (FileNotFoundException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
  }
  public void testFileDiff() {
    try {
      FileInputStream f1 = new FileInputStream("temp\\d1.txt");
      FileInputStream f2 = new FileInputStream("temp\\d2.txt");
      assertEquals(comparator.compare(null, f1, f2, null, null), 100);
    } catch (FileNotFoundException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
    try {
      FileInputStream f1 = new FileInputStream("temp\\e1.txt");
      FileInputStream f2 = new FileInputStream("temp\\e2.txt");
      assertEquals(comparator.compare(null, f1, f2, null, null), 0);
    } catch (FileNotFoundException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
  }
}
